/*
 * @lc app=leetcode.cn id=27 lang=golang
 *
 * [27] 移除元素
 */
package main

import "fmt"

// @lc code=start
func removeElement(nums []int, val int) int {
	i := 0
	for j := 0; j < len(nums); j++ {
		if nums[j] != val {
			nums[i] = nums[j]
			i++
		}
	}
	return i
}

// @lc code=end

func main() {
	nums := []int{3, 2, 2, 3}
	val := 2
	fmt.Println(removeElement(nums, val))
	fmt.Printf("%v", nums)
}
